<template>
	<div class="px-5 py-2 main-content-bg-color">
		<el-button type="primary" @click="onSubmit">清除记录</el-button>
		<card :data="lastuse" :showTitle="false" :isLastuse="true" dataName="lastuse"></card>
	</div>
</template>

<script>
import card from '@/components/card/card.vue';
var storage = window.sessionStorage;
import {mapState,mapMutations} from "vuex"
export default {
	components: {
		card
	},
	computed:{
		...mapState(['lastuse'])
	},
	
	methods: {
		...mapMutations(['clearLastuse']),
		onSubmit() {
			

			if (this.lastuse && this.lastuse.length > 0) {
				
				this.clearLastuse();
				this.$message({
					message: '删除成功',
					type: 'success'
				});
				storage.setItem('activeIndex', JSON.stringify(1));
				return this.$router.push({
					name: 'index_list'
				});
			}
		}
	},
	mounted() {
		
		if (this.lastuse.length === 0) {
			this.$message({
				message: '暂无最近使用记录',
				type: 'warning'
			});
			setTimeout(() => {
				storage.setItem('activeIndex', 1);
			}, 100);
			return this.$router.push({
				name: 'index_list'
			});
		}

		
		
	}
};
</script>

<style></style>
